import { autorun, bind, observable } from "./Observe";

let data = observable({
    atk: 100,
    hp: 200
});

autorun(() => {
    console.log('atk change', data.atk);
});


let str_atk = "";
autorun(() => {
    str_atk = "atk: " + data.atk;
    console.log('atk string -- ', str_atk);
});

data.atk = 322;
data.atk = 2312;

let role = observable({
    atk: 10,
    pet: null,
});

let pet = observable({
    atk: 100
});

autorun(() => {
    let damage = role.atk + (role.pet ? role.pet.atk : 0);
    role.damage = damage;
    console.log('role damage:', damage);
});

role.pet = pet;

pet.atk += 30;

let pet2 = observable({
    atk: 333
});
role.pet = pet2;